<?php
/*
Template Name: Portfolio Page
*/

get_header(); // Loads the header.php template. ?>		
		
		<div id="main" class="page-portfolio clearfix">			
			
			<div class="page-center clearfix">	
			
				<section id="options" class="clearfix">
				
					<ul id="portfolio-filter" class="option-set" data-option-key="filter">
						<li><a href="#filter" data-option-value="*" class="selected"><?php _e('show all', hybrid_get_textdomain()); ?></a></li>
						<?php 
						if(count($cv_option['pf_categories']['enabled']) > 1) {	
							foreach((get_categories('include='. get_categories_id($cv_option['pf_categories']['enabled']))) as $category) { ?>				
								<li><a class=""  href="#filter" title="" data-option-value=".<?php echo $category->category_nicename;?>"><?php echo $category->cat_name;?></a></li>
							<?php } 
						} ?>				
					</ul>						
				
				</section> <!-- #options -->					
				
				<div id="content" class="clearfix">
				<div id="portfolio-list" class="<?php echo $cv_option['pf_show_image_excerpt']; ?> clearfix isotope">
					<?php if(count($cv_option['pf_categories']['enabled']) > 1) {						
						$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
						query_posts(array('showposts' => $cv_option['pf_item_amount'], 'cat' => get_categories_id($cv_option['pf_categories']['enabled']), 'paged'=>$paged)); ?>
						<?php $i=0; if(have_posts()) : while (have_posts()) : the_post(); $i++?>
							<div id="post-<?php the_ID(); ?>" class="<?php echo $cv_option['pf_show_image_excerpt'] . ' ' . $cv_option['pf_portfolio_style'];?> <?php foreach((get_the_category()) as $category) echo ' ' . $category->category_nicename;?> element isotope-item hentry"> 
								<?php
								$thumb_size = 'thumbnail'; $excerpt_length = 200;
								if ($cv_option['pf_portfolio_style']=='four-column') {$thumb_size = 'four-column-thumb'; $excerpt_length = 115; $no_pic = 'pf-no-pic-small.gif'; }
								else if ($cv_option['pf_portfolio_style']=='three-column')  {$thumb_size = 'three-column-thumb'; $excerpt_length = 150; $no_pic = 'pf-no-pic-media.gif'; }
								else if ($cv_option['pf_portfolio_style']=='two-column')  {$thumb_size = 'two-column-thumb'; $excerpt_length = 200; $no_pic = 'pf-no-pic-large.gif';}
								?>
								<div class="entry-img">								
									<?php if ( current_theme_supports( 'get-the-image' ) ) {																	
										
										$thumb2 = get_the_image( array( 'format' => 'array', 'echo' => false, 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => $thumb_size ) ); 
										if ( !empty( $thumb2['src'] ) ) { ?>
												<a href="<?php echo esc_url(get_permalink());?>"></a>
												<strong></strong>
												<img src="<?php echo $thumb2['src'];?>">										
										<?php } 
										 else { ?>
										  <a href="<?php echo esc_url(get_permalink());?>"></a>
											<strong></strong>
											<img src="<?php echo get_bloginfo('template_directory').'/images/'. $no_pic; ?>">
										<?php } 
									} ?>							
								</div><!-- .entry-image -->	
								<?php if ( $cv_option['pf_show_image_excerpt'] == 'show-excerpt' ) {	?>
									<div class="portfolio-center">
										<h3 class="entry-title"><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></h3>	
										<div class="entry-content">							
											<?php print_excerpt($excerpt_length); ?>
										</div><!-- .entry-summary -->	
									</div>
								<?php } ?>		
							</div><!-- .hentry -->	
							
						<?php endwhile; ?>						
						<?php endif; ?>
							
					<?php } ?>	
				</div> <!-- #portfolio-list -->	
				<div id="nav-below" class="page_navi">						 
							<?php cv_pagenavi(); ?> 
						</div><!-- #nav-below -->				
						<?php wp_reset_query(); 	?>
			</div> <!-- #content -->		
			
			</div><!-- .center -->
		</div><!-- #main -->		
	
<?php get_footer(); // Loads the footer.php template. ?>		